<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Dashboard Template for Bootstrap</title>
    <!-- Bootstrap core CSS -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="../css/dashboard.css" rel="stylesheet">

      <style>
          .hide{
              display: none;
          }
          .main{
              width: 90%;
          }
          .sidebar{
              width: 10%;
              top: 50px;
          }
          .col-md-offset-2{
              margin-left: 10%;
          }
          td{
              max-width: 200px;
              text-overflow: ellipsis;
              white-space: nowrap; /*禁止自动换行*/
              overflow: hidden;
          }
      </style>

  </head>

  <body>

    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Project name</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Dashboard</a></li>
            <li><a href="#">Settings</a></li>
            <li><a href="#">Profile</a></li>
            <li><a href="#">Help</a></li>
          </ul>
          <form class="navbar-form navbar-right">
            <input type="text" class="form-control" placeholder="Search...">
          </form>
        </div>
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
          <ul class="nav nav-sidebar">
            <li class="active"><a href="#">site<span class="sr-only">(current)</span></a></li>
            <li class="job51"><a href="#">51Job</a></li>
            <li class="add"><a href="#">Boos</a></li>
            <li><a href="#">拉钩</a></li>
          </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <h1 class="page-header hide" >Dashboard</h1>

          <div class="row placeholders hide">
            <div class="col-xs-6 col-sm-3 placeholder">
              <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
            <div class="col-xs-6 col-sm-3 placeholder">
              <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
            <div class="col-xs-6 col-sm-3 placeholder">
              <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
            <div class="col-xs-6 col-sm-3 placeholder">
              <img src="" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail">
              <h4>Label</h4>
              <span class="text-muted">Something else</span>
            </div>
          </div>

          <h2 class="sub-header">Item</h2>
          <div class="table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>#</th>
                  <th>companyName</th>
                  <th>companyAddr</th>
                  <th>companyInfo</th>
                  <th>jobName</th>
                  <th>jobAddr</th>
                    <th>jobInfo</th>
                    <th>salaryMin</th>
                    <th>salaryMax</th>
                    <th>time</th>
                    <th>operation</th>
                    <th>url</th>
                </tr>
              </thead>
              <tbody class="tbody_content">
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
    <script src="../js/jquery-3.5.1.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script type="text/javascript">

        $(function () {
            jobInfo();
        });

        $(".add").click(function(){
            alert($(this).text());
        });

        $(".job51").click(function(){
            console.log("51job clink")
            jobInfo();
        })

        function jobInfo() {
            // $.get("/list", function(result)
            $.get("http://localhost:9092/list", function(result){
                //$("div").html(result);
                //console.log(result)
                let data = JSON.parse(result);
                if(data.code == 200){
                    let list = data.result;
                    $(".tbody_content").empty();
                    for (let key in list) {
                        let item = list[key];
                        let trHtml = "<tr>";
                        trHtml +="<td>"+key.toString()+"</td>"
                            +"<td>"+item['companyName']+"</td>"
                            +"<td title='"+item['companyAddr']+"'>"+item['companyAddr']+"</td>"
                            +"<td title='"+item['companyInfo']+"'>"+item['companyInfo']+"</td>"
                            +"<td>"+item['jobName']+"</td>"
                            +"<td>"+item['jobAddr']+"</td>"
                            +"<td title='"+item['jobInfo']+"'>"+item['jobInfo']+"</td>"
                            +"<td>"+item['salaryMin']+"</td>"
                            +"<td>"+item['salaryMax']+"</td>"
                            +"<td>"+item['time']+"</td>"
                            +"<td><a href='#'>first</a>&nbsp;<a href='#'>last</a></td>"
                            +"<td><a target=\"_blank\" href=\'"+item['url']+"\'>查看</a></td>"
                        //console.log(str)
                        trHtml+="</tr>";
                        $(".tbody_content").append(trHtml)
                    }
                }
            });
        }
    </script>
  </body>

</html>
